//
//  BaseLabel.m
//  New
//
//  Created by dlios on 15-7-17.
//  Copyright (c) 2015年 yangTao. All rights reserved.
//

#import "BaseLabel.h"

@implementation BaseLabel
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        
        if ([@"on"isEqualToString:[user objectForKey:@"night"]]) {
            
            
            self.textColor = [UIColor whiteColor];

            
        }
        else{
           self.textColor = [UIColor blackColor];

        }
        
        NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
        [notification addObserver:self selector:@selector(changeNight:) name:@"changeNight" object:nil];
    
    }

    return self;
}

-(void)changeNight:(NSNotification *)notification{
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    [user setObject:(NSString *)[notification object] forKey:@"night"];
    
    if ([@"on"isEqualToString:[user objectForKey:@"night"]]) {
        
       self.textColor = [UIColor whiteColor];
        
    }
    else{
         self.textColor = [UIColor blackColor];
    }
    

}

- (void)dealloc{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeNight" object:nil];
   
}


@end
